#include <stdio.h>
#include <iostream>
#include <malloc.h>
using namespace std;

typedef struct node
{
    int coefficient;
    int power;
    node *next;
} node, *Linklist;

Linklist Px; // p1(x) expression

// head insert
int insert(int coefficient, int power)
{
    node *newNode = (node *)malloc(sizeof(node));
    newNode->coefficient = coefficient;
    newNode->power = power;
    newNode->next = Px;
    Px = newNode;
    return 1;
}

void printPx()
{
    node *p = Px;
    while (p->next != NULL)
    {
        cout << ((p->coefficient >= 0) ? "+" : "") << p->coefficient << "x^(" << p->power << ")";
        p = p->next;
    }
    cout << endl;
}

int main()
{
    // initialization of  Px
    Px = (node *)malloc(sizeof(node));
    Px->next = NULL;
    Px->coefficient = 0;
    Px->power = -1;

    // generate Px
    insert(-25, 1);
    insert(6, 30);
    insert(88, 40);

    // print Px
    printPx();

    return 0;
}
